package org.qiyu.live.gift.provider.rpc;

import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.live.frmework.web.starter.context.QiyuRequestContext;
import org.qiyu.live.common.interfaces.utils.ConvertBeanUtils;
import org.qiyu.live.gift.interfaces.dto.ShopCarReqDTO;
import org.qiyu.live.gift.interfaces.dto.ShopCarReqVO;
import org.qiyu.live.gift.interfaces.dto.ShopCarRespDTO;
import org.qiyu.live.gift.interfaces.dto.ShopCarRespVO;
import org.qiyu.live.gift.interfaces.rpc.IShopCarRpc;
import org.qiyu.live.gift.provider.service.IShopCarService;

@DubboService
public class ShopCarRpcImpl implements IShopCarRpc {

    @Resource
    private IShopCarService shopCarService;
    @DubboReference
    private IShopCarRpc shopCarRpc;

    @Override
    public Boolean addCar(ShopCarReqDTO shopCarReqDTO) {
        return shopCarService.addCar(shopCarReqDTO);
    }

    @Override
    public Boolean removeFromCar(ShopCarReqDTO shopCarReqDTO) {
        return shopCarService.removeFromCar(shopCarReqDTO);
    }

    @Override
    public Boolean clearShopCar(ShopCarReqDTO shopCarReqDTO) {
        return shopCarService.clearShopCar(shopCarReqDTO);
    }

    @Override
    public Boolean addCarItemNum(ShopCarReqDTO shopCarReqDTO) {
        return shopCarService.addCarItemNum(shopCarReqDTO);
    }

    public ShopCarRespVO getCarInfo(ShopCarReqDTO shopCarReqDTO) {
        ShopCarRespVO carInfo = shopCarRpc.getCarInfo(new ShopCarReqDTO(shopCarReqDTO.getUserId(), shopCarReqDTO.getSkuId(), shopCarReqDTO.getRoomId()));
        ShopCarRespVO respVO = ConvertBeanUtils.convert(carInfo, ShopCarRespVO.class);
        return respVO;
    }
}